package com.tjsinfo.tjsoa.documentationflow.dangweifawen.bo;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;

import com.tjsinfo.tjsoa.Dao.IQbcDao;
import com.tjsinfo.tjsoa.documentationflow.dangweifawen.dao.ITDangweifawendengjibuDAO;
import com.tjsinfo.tjsoa.documentationflow.dangweifawen.vo.TDangweifawendengjibu;

public class TDangweifawendengjibuBO implements ITDangweifawendengjibuBO{
	private ITDangweifawendengjibuDAO dangweifawendengjibuDAO;
	private IQbcDao qbcDao;
	
	public IQbcDao getQbcDao() {
		return qbcDao;
	}

	public void setQbcDao(IQbcDao qbcDao) {
		this.qbcDao = qbcDao;
	}

	public ITDangweifawendengjibuDAO getDangweifawendengjibuDAO() {
		return dangweifawendengjibuDAO;
	}

	public void setDangweifawendengjibuDAO(
			ITDangweifawendengjibuDAO dangweifawendengjibuDAO) {
		this.dangweifawendengjibuDAO = dangweifawendengjibuDAO;
	}

	public Boolean addTdangweifawendangjibu(
			TDangweifawendengjibu dangweifawendengjibu) {
		// TODO Auto-generated method stub
		try {
			dangweifawendengjibuDAO.save(dangweifawendengjibu);
			return true;
		} catch (RuntimeException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return false;
	}

	public List<TDangweifawendengjibu> selectAll() {
		// TODO Auto-generated method stub
		DetachedCriteria criteria = DetachedCriteria.forClass(TDangweifawendengjibu.class);
		return qbcDao.getCriteria(criteria);
	
	}

	public TDangweifawendengjibu selectByDocId(String docid) {
		// TODO Auto-generated method stub
		DetachedCriteria criteria = DetachedCriteria.forClass(TDangweifawendengjibu.class);
		criteria.add(Restrictions.eq("docid", docid));
		List<TDangweifawendengjibu> list = qbcDao.getCriteria(criteria);
		if (list.size() > 0) {
			TDangweifawendengjibu dangweifawendengjibu = list.get(0);
			return dangweifawendengjibu;
		}
		return null;
	}
	
	public Boolean updateTdangweidengjibu(TDangweifawendengjibu dangweifawendengjibu){
		try {
			dangweifawendengjibuDAO.merge(dangweifawendengjibu);
			return true;
		} catch (RuntimeException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return false;
	}

	public List<TDangweifawendengjibu> select(DetachedCriteria criteria) {
		// TODO Auto-generated method stub
		return qbcDao.getCriteria(criteria);
	}
	
}
